<template>
  <div>
    <el-dialog title="公式配置" :visible.sync="dialogVisible" width="1200px" top="8vh" append-to-body>
      <el-form :model="dataForm" ref="dataForm">
        <el-container>
          <el-main style="height:calc(100vh  - 420px); padding: 0 45px;">
            <el-row :gutter="20">
              <el-col :span="18">
                <el-form-item>
                  <el-card class="box-card" style="margin-top: 0px; height:calc(100vh  - 450px); overflow-y: auto;">
                    <div class="h50 font22">公式内容</div>
                    <div v-if="gsPz.length==0">当前无公式</div>
                    <div v-else>
                      <draggable v-model="gsPz" chosenClass="chosen" forceFallback="true" group="people" animation="200"
                                 @start="onStart" @end="onEnd">
                        <transition-group>
                          <span v-for="(t,ii) in gsPz" :key="t.i">
                            <span v-if="t.type=='过程项'">
                              <el-select v-model="t.id" placeholder="请选择" style="margin: 10px;">
                                <el-option
                                  v-for="(item,j) in list"
                                  :key="j"
                                  :label="item.name"
                                  :value="item.code">
                                </el-option>
                              </el-select>
                            </span>
                            <span v-if="t.type=='常数项'">
                              <el-input v-model="t.number" label="请填写" style="width:60px;margin: 10px;"></el-input>
                            </span>
                            <span v-if="t.type=='范围项'">
                              【
                              <span v-if="t.classify=='大于项'">
                                <el-input v-model="t.min" label="请填写" style="width:100px;margin: 10px;"></el-input>
                                ＜ 分值 ＝
                                <el-input v-model="t.number" label="请填写" style="width:60px;margin: 10px;"></el-input>
                              </span>
                              <span v-if="t.classify=='小于项'">
                                分值 ≤
                                <el-input v-model="t.max" label="请填写" style="width:100px;margin: 10px;"></el-input>
                                ＝
                                <el-input v-model="t.number" label="请填写" style="width:60px;margin: 10px;"></el-input>
                              </span>
                              <span v-if="t.classify=='大小于项'">
                                <el-input v-model="t.min" label="请填写" style="width:100px;margin: 10px;"></el-input>
                                ＜ 分值 ≤
                                <el-input v-model="t.max" label="请填写" style="width:100px;margin: 10px;"></el-input>
                                ＝
                                <el-input v-model="t.number" label="请填写" style="width:60px;margin: 10px;"></el-input>
                              </span>
                              】
                            </span>
                            <span v-if="t.type=='符号项'">
                              <img src="/images/jia.png" style="width: 30px;vertical-align: middle;"
                                   v-if="t.value=='+'"/>
                              <img src="/images/jian.png" style="width: 30px;vertical-align: middle;"
                                   v-if="t.value=='-'"/>
                              <img src="/images/cheng.png" style="width: 30px;vertical-align: middle;"
                                   v-if="t.value=='*'"/>
                              <img src="/images/chu.png" style="width: 30px;vertical-align: middle;"
                                   v-if="t.value=='/'"/>
                              <img src="/images/kuo1.png" style="width: 30px;vertical-align: middle;"
                                   v-if="t.value=='('"/>
                              <img src="/images/kuo2.png" style="width: 30px;vertical-align: middle;"
                                   v-if="t.value==')'"/>
                            </span>
                          </span>
                        </transition-group>
                      </draggable>
                    </div>
                  </el-card>
                </el-form-item>
              </el-col>
              <el-col :span="6">
                <el-row :gutter="10">
                  <el-col :span="24">
                    <el-button @click="add('过程项')" class="anNiu mb10 h75"
                               v-show="!(gsPz.length>0&&gsPz[0].type=='范围项')">过程项
                    </el-button>
                  </el-col>
                  <el-col :span="24">
                    <el-button class="anNiu mb10 h75" @click="add('常数项')"
                               v-show="!(gsPz.length>0&&gsPz[0].type=='范围项')">常数项
                    </el-button>
                  </el-col>
                  <el-col :span="8">
                    <el-button class="anNiuFh mb10 h75 anNiu2" @click="add('+')"
                               v-show="!(gsPz.length>0&&gsPz[0].type=='范围项')"><i class="el-icon-plus"></i>
                    </el-button>
                  </el-col>
                  <el-col :span="8">
                    <el-button class="anNiuFh mb10 h75 anNiu2" @click="add('-')"
                               v-show="!(gsPz.length>0&&gsPz[0].type=='范围项')"><i class="el-icon-minus"></i>
                    </el-button>
                  </el-col>
                  <el-col :span="8">
                    <el-button class="anNiuFh mb10 h75 anNiu2" @click="add('*')"
                               v-show="!(gsPz.length>0&&gsPz[0].type=='范围项')"><i class="el-icon-close"></i>
                    </el-button>
                  </el-col>
                  <el-col :span="8">
                    <el-button class="anNiuFh mb10 h75 anNiu3" @click="add('/')"
                               v-show="!(gsPz.length>0&&gsPz[0].type=='范围项')"><span>÷</span></el-button>
                  </el-col>
                  <el-col :span="8">
                    <el-button class="anNiuFh mb10 h75 anNiu2" @click="add('(')"
                               v-show="!(gsPz.length>0&&gsPz[0].type=='范围项')">(
                    </el-button>
                  </el-col>
                  <el-col :span="8">
                    <el-button class="anNiuFh mb10 h75 anNiu2" @click="add(')')"
                               v-show="!(gsPz.length>0&&gsPz[0].type=='范围项')">)
                    </el-button>
                  </el-col>
                  <el-col :span="24">
                    <el-button @click="add('小于项')" class="anNiu mb10 h75"
                               v-if="dataForm.gsType=='合同算法'||dataForm.gsType=='考核算法' || dataForm.gsType=='任务书算法' ">小于范围项
                    </el-button>
                  </el-col>
                  <el-col :span="24">
                    <el-button @click="add('大小于项')" class="anNiu mb10 h75"
                               v-if="dataForm.gsType=='合同算法'||dataForm.gsType=='考核算法' || dataForm.gsType=='任务书算法' ">大于&小于范围项
                    </el-button>
                  </el-col>
                  <el-col :span="24">
                    <el-button @click="add('大于项')" class="anNiu mb10 h75"
                               v-if="dataForm.gsType=='合同算法'||dataForm.gsType=='考核算法' || dataForm.gsType=='任务书算法' ">大于范围项
                    </el-button>
                  </el-col>
                  <el-col :span="24">
                    <el-button class="anNiuTui mb10 h75" @click="del" v-if="gsPz.length>0">回退</el-button>
                  </el-col>
                </el-row>
              </el-col>
            </el-row>
          </el-main>
        </el-container>
      </el-form>
      <span slot="footer" class="dialog-footer">
        
        <el-button type="primary" @click="save">保存</el-button>
        <el-button @click="dialogVisible = false">关闭</el-button>
      </span>
    </el-dialog>
  </div>
</template>

<script>
import draggable from 'vuedraggable'
import {getObj, addObj, putObj} from '@/api/admin/sysformula'

export default {
  name: "jiangjingspzb-config",
  components: {
    draggable
  },
  data() {
    return {
      dialogVisible: false,
      dataForm: {},
      gsPz: [],
      options: {
        process1001: {ptype: "奖金算法", type: "个人", code: "process1001", name: "奖金总额", ysList: []},
        process1002: {ptype: "奖金算法", type: "个人", code: "process1002", name: "加扣奖总额", ysList: []},
        process1003: {ptype: "奖金算法", type: "个人", code: "process1003", name: "分组员工总数", ysList: []},
        process1011: {ptype: "奖金算法", type: "个人", code: "process1011", name: "员工岗位系数", ysList: []},
        process1012: {ptype: "奖金算法", type: "个人", code: "process1012", name: "分组（员工岗位系数）总和", ysList: []},
        process1021: {ptype: "奖金算法", type: "个人", code: "process1021", name: "员工考核基础分", ysList: []},
        process1022: {ptype: "奖金算法", type: "个人", code: "process1022", name: "分组（员工考核基础分）总和", ysList: []},
        process1031: {ptype: "奖金算法", type: "个人", code: "process1031", name: "员工月绩效考核分", ysList: []},
        process1032: {ptype: "奖金算法", type: "个人", code: "process1032", name: "分组（员工月绩效考核分）总和", ysList: []},
        process1041: {ptype: "奖金算法", type: "个人", code: "process1041", name: "员工岗位系数×考核基础分", ysList: []},
        process1042: {ptype: "奖金算法", type: "个人", code: "process1042", name: "分组（员工岗位系数×考核基础分）总和", ysList: []},
        process1051: {ptype: "奖金算法", type: "个人", code: "process1051", name: "员工岗位系数×月绩效考核分", ysList: []},
        process1052: {ptype: "奖金算法", type: "个人", code: "process1052", name: "分组（员工岗位系数×月绩效考核分）总和", ysList: []},
        // process1091: {ptype: "奖金算法", type: "个人", code: "process1091", name: "专项奖励", ysList: []},
        // process1092: {ptype: "奖金算法", type: "个人", code: "process1092", name: "工时（工作量）奖励", ysList: []},
        // process1093: {ptype: "奖金算法", type: "个人", code: "process1093", name: "奖励标准奖金", ysList: []},
        process2001: {ptype: "奖金算法", type: "个人", code: "process2001", name: "绩效年薪基数", ysList: []},
        process2002: {ptype: "奖金算法", type: "个人", code: "process2002", name: "综合业绩分值", ysList: []},
        process2007: {ptype:"奖金算法",type: "个人", code: "process2007", name: "人员年度履历月份数", ysList: []},
        process2003: {ptype: "奖金算法", type: "个人", code: "process2003", name: "绩效奖金基数", ysList: []},
        process2004: {ptype: "奖金算法", type: "个人", code: "process2004", name: "个人绩效分数", ysList: []},
        // process2005: {ptype: "奖金算法", type: "个人", code: "process2005", name: "B级绩效分值指数", ysList: []},
        // process2006: {ptype: "奖金算法", type: "个人", code: "process2006", name: "分组（员工B级绩效分值指数）总和", ysList: []},
        process2010: {ptype: "奖金算法", type: "个人", code: "process2010", name: "二级正领导年奖金公式（独立集成计算）（包含履历计算）", ysList: []},
        process2011: {ptype: "奖金算法", type: "个人", code: "process2011", name: "二级副领导年奖金公式（独立集成计算）（包含履历计算）", ysList: []},
        process2009: {ptype:"奖金算法",type: "个人", code: "process2009", name: "分组考核A级起点分数", ysList: []},
        process2012: {ptype:"奖金算法",type: "个人", code: "process2012", name: "分组考核A级最高分数", ysList: []},
        process2013: {ptype:"奖金算法",type: "个人", code: "process2013", name: "分组考核B级起点分数", ysList: []},
        process2014: {ptype:"奖金算法",type: "个人", code: "process2014", name: "分组考核B级最高分数", ysList: []},
        process2015: {ptype:"奖金算法",type: "个人", code: "process2015", name: "分组考核C级起点分数", ysList: []},
        process2016: {ptype:"奖金算法",type: "个人", code: "process2016", name: "分组考核C级最高分数", ysList: []},
        //A1-D2
        process2029: {ptype:"奖金算法",type: "个人", code: "process2029", name: "分组考核A1级起点分数", ysList: []},
        process2030: {ptype:"奖金算法",type: "个人", code: "process2030", name: "分组考核A1级最高分数", ysList: []},
        process2031: {ptype:"奖金算法",type: "个人", code: "process2031", name: "分组考核B1级起点分数", ysList: []},
        process2032: {ptype:"奖金算法",type: "个人", code: "process2032", name: "分组考核B1级最高分数", ysList: []},
        process2033: {ptype:"奖金算法",type: "个人", code: "process2033", name: "分组考核C1级起点分数", ysList: []},
        process2034: {ptype:"奖金算法",type: "个人", code: "process2034", name: "分组考核C1级最高分数", ysList: []},
        process2035: {ptype:"奖金算法",type: "个人", code: "process2035", name: "分组考核D1级起点分数", ysList: []},
        process2036: {ptype:"奖金算法",type: "个人", code: "process2036", name: "分组考核D1级最高分数", ysList: []},
        process2037: {ptype:"奖金算法",type: "个人", code: "process2037", name: "分组考核A2级起点分数", ysList: []},
        process2038: {ptype:"奖金算法",type: "个人", code: "process2038", name: "分组考核A2级最高分数", ysList: []},
        process2039: {ptype:"奖金算法",type: "个人", code: "process2039", name: "分组考核B2级起点分数", ysList: []},
        process2040: {ptype:"奖金算法",type: "个人", code: "process2040", name: "分组考核B2级最高分数", ysList: []},
        process2041: {ptype:"奖金算法",type: "个人", code: "process2041", name: "分组考核C2级起点分数", ysList: []},
        process2042: {ptype:"奖金算法",type: "个人", code: "process2042", name: "分组考核C2级最高分数", ysList: []},
        process2043: {ptype:"奖金算法",type: "个人", code: "process2043", name: "分组考核D2级起点分数", ysList: []},
        process2044: {ptype:"奖金算法",type: "个人", code: "process2044", name: "分组考核D2级最高分数", ysList: []},
        //A1-D2
        // process2017: {ptype:"奖金算法",type: "个人", code: "process2017", name: "分组考核D级起点分数", ysList: []},
        // process2018: {ptype:"奖金算法",type: "个人", code: "process2018", name: "分组考核D级最高分数", ysList: []},
        process2020: {ptype: "奖金算法", type: "个人", code: "process2020", name: "业务人员年奖金公式（独立集成计算）", ysList: []},
        // process2021: {ptype:"奖金算法",type: "个人", code: "process2021", name: "分组考核A档最低分数", ysList: []},
        // process2022: {ptype:"奖金算法",type: "个人", code: "process2022", name: "分组考核A档最高分数", ysList: []},
        // process2023: {ptype:"奖金算法",type: "个人", code: "process2023", name: "分组考核B档最低分数", ysList: []},
        // process2024: {ptype:"奖金算法",type: "个人", code: "process2024", name: "分组考核B档最高分数", ysList: []},
        // process2025: {ptype:"奖金算法",type: "个人", code: "process2025", name: "分组考核C档最低分数", ysList: []},
        // process2026: {ptype:"奖金算法",type: "个人", code: "process2026", name: "分组考核C档最高分数", ysList: []},
        // process2027: {ptype:"奖金算法",type: "个人", code: "process2027", name: "分组考核D档最低分数", ysList: []},
        // process2028: {ptype:"奖金算法",type: "个人", code: "process2028", name: "分组考核D档最高分数", ysList: []},

        process3001: {ptype: "奖金算法", type: "个人", code: "process3001", name: "职级分级奖金系数", ysList: []},
        process3002: {ptype: "奖金算法", type: "个人", code: "process3002", name: "分组（职级分级奖金系数）总和", ysList: []},
        process3003: {ptype: "奖金算法", type: "个人", code: "process3003", name: "职级分级月奖基数", ysList: []},
        process3004: {ptype: "奖金算法", type: "个人", code: "process3004", name: "分组（职级分级月奖基数）总和", ysList: []},
        process3005: {ptype: "奖金算法", type: "个人", code: "process3005", name: "职级分级年奖基数", ysList: []},
        process3006: {ptype: "奖金算法", type: "个人", code: "process3006", name: "分组（职级分级年奖基数）总和", ysList: []},

        process3021: {ptype: "奖金算法", type: "个人", code: "process3021", name: "职级默认奖金系数", ysList: []},
        process3022: {ptype: "奖金算法", type: "个人", code: "process3022", name: "分组（职级默认奖金系数）总和", ysList: []},
        process3023: {ptype: "奖金算法", type: "个人", code: "process3023", name: "职级默认月奖基数", ysList: []},
        process3024: {ptype: "奖金算法", type: "个人", code: "process3024", name: "分组（职级默认月奖基数）总和", ysList: []},
        process3025: {ptype: "奖金算法", type: "个人", code: "process3025", name: "职级默认年奖基数", ysList: []},
        process3026: {ptype: "奖金算法", type: "个人", code: "process3026", name: "分组（职级默认年奖基数）总和", ysList: []},

        process3011: {ptype: "奖金算法", type: "个人", code: "process3011", name: "个人奖金系数", ysList: []},
        process3012: {ptype: "奖金算法", type: "个人", code: "process3012", name: "分组（个人奖金系数）总和", ysList: []},
        process3013: {ptype: "奖金算法", type: "个人", code: "process3013", name: "个人月奖基数", ysList: []},
        process3014: {ptype: "奖金算法", type: "个人", code: "process3014", name: "分组（个人月奖基数）总和", ysList: []},
        process3015: {ptype: "奖金算法", type: "个人", code: "process3015", name: "个人年奖基数", ysList: []},
        process3016: {ptype: "奖金算法", type: "个人", code: "process3016", name: "分组（个人年奖基数）总和", ysList: []},

        process5001: {ptype: "奖金算法", type: "部门", code: "process5001", name: "奖金总额", ysList: []},
        process5003: {ptype: "奖金算法", type: "部门", code: "process5003", name: "分组部门总数", ysList: []},
        process5011: {ptype: "奖金算法", type: "部门", code: "process5011", name: "部门职能系数", ysList: []},
        process5012: {ptype: "奖金算法", type: "部门", code: "process5012", name: "分组（部门职能系数）总和", ysList: []},
        process5021: {ptype: "奖金算法", type: "部门", code: "process5021", name: "部门考核基础分", ysList: []},
        process5022: {ptype: "奖金算法", type: "部门", code: "process5022", name: "分组（部门考核基础分）总和", ysList: []},
        process5041: {ptype: "奖金算法", type: "部门", code: "process5041", name: "部门职能系数×考核基础分", ysList: []},
        process5042: {ptype: "奖金算法", type: "部门", code: "process5042", name: "分组（部门职能系数×考核基础分）总和", ysList: []},

        process5051: {ptype: "合同算法", type: "部门", code: "process5051", name: "目标值", ysList: []},
        process5052: {ptype: "合同算法", type: "部门", code: "process5052", name: "完成值", ysList: []},

        process3031: {ptype: "合同算法", type: "个人", code: "process3031", name: "目标值", ysList: []},
        process3032: {ptype: "合同算法", type: "个人", code: "process3032", name: "完成值", ysList: []},

        process5053: {ptype: "任务书算法", type: "部门", code: "process5053", name: "目标值", ysList: []},
        process5054: {ptype: "任务书算法", type: "部门", code: "process5054", name: "完成值", ysList: []},

        process3033: {ptype: "任务书算法", type: "个人", code: "process3033", name: "目标值", ysList: []},
        process3034: {ptype: "任务书算法", type: "个人", code: "process3034", name: "完成值", ysList: []},

        process6001: {ptype: "奖金算法", type: "个人", code: "process6001", name: "副职年薪标准", ysList: []},
        process6002: {ptype: "奖金算法", type: "个人", code: "process6002", name: "正职年薪总额", ysList: []},
        process6003: {ptype: "奖金算法", type: "个人", code: "process6003", name: "副职人数", ysList: []},
        process6004: {ptype: "奖金算法", type: "个人", code: "process6004", name: "个人综合业绩分值", ysList: []},
        process6005: {ptype: "奖金算法", type: "个人", code: "process6005", name: "副职综合业绩分值之和", ysList: []},
        process6006: {ptype: "奖金算法", type: "个人", code: "process6006", name: "正职年薪总额(机关)", ysList: []},
        process6007: {ptype: "奖金算法", type: "个人", code: "process6007", name: "个人奖励标准奖金", ysList: []},

        //news日常考核算法规则
        process5055: {ptype: "考核算法", type: "部门", code: "process5055", name: "目标值", ysList: []},
        process5056: {ptype: "考核算法", type: "部门", code: "process5056", name: "完成值", ysList: []},

        process3035: {ptype: "考核算法", type: "个人", code: "process3035", name: "目标值", ysList: []},
        process3036: {ptype: "考核算法", type: "个人", code: "process3036", name: "完成值", ysList: []},

        //news日常考核-考核汇总算法规则
        process5057: {ptype: "考核汇总", type: "部门", code: "process5057", name: "指标分", ysList: []},
        process5058: {ptype: "考核汇总", type: "部门", code: "process5058", name: "事件分", ysList: []},
        process5059: {ptype: "考核汇总", type: "部门", code: "process5059", name: "事件加减分", ysList: []},

        process3037: {ptype: "考核汇总", type: "个人", code: "process3037", name: "指标分", ysList: []},
        process3038: {ptype: "考核汇总", type: "个人", code: "process3038", name: "事件分", ysList: []},
        process3039: {ptype: "考核汇总", type: "个人", code: "process3039", name: "事件加减分", ysList: []},

        //统计分析算法 start  by mingyue （只加一行）
        process3040: {ptype: "统计分析算法", type: "个人", code: "process3040", name: "单项分数值", ysList: []},
        process5060: {ptype: "统计分析算法", type: "部门", code: "process5060", name: "单项分数值", ysList: []},

      },
      list: []
    }
  },
  methods: {
    init(id) {
      this.dataForm.id = id || 0;
      this.$nextTick(() => {
        if (this.dataForm.id) {
          getObj(this.dataForm.id).then(response => {
              if(response.data.data) {

                  this.dataForm = response.data.data;

                  this.list = [];
                  for (var i in this.options) {
                      if (this.options[i].type == this.dataForm.gsFl && this.options[i].ptype == this.dataForm.gsType) {
                          this.list.push(this.options[i]);
                      }
                  }

                  if (!this.dataForm.gsPz) {
                      this.gsPz = [];
                  } else {
                      this.gsPz = JSON.parse(this.dataForm.gsPz);
                  }
                  this.dialogVisible = true;
              }
          })
        }
      })
    },
    add(t) {
      if (t == "过程项") {
        this.gsPz.push(
          {
            i: this.getUUID(),
            type: "过程项",
            id: ""
          }
        )
      } else if (t == "常数项") {
        this.gsPz.push(
          {
            i: this.getUUID(),
            type: "常数项",
            number: 1
          }
        )
      } else if (t == "大于项") {
        if (this.gsPz.length > 0) {
          if (this.gsPz[0].type != '范围项') {
            this.gsPz = [];
          }
        }
        this.gsPz.push(
          {
            i: this.getUUID(),
            type: "范围项",
            classify: "大于项",
            max: 0,
            min: 1000,
            number: 100
          }
        )
      } else if (t == "大小于项") {
        if (this.gsPz.length > 0) {
          if (this.gsPz[0].type != '范围项') {
            this.gsPz = [];
          }
        }
        this.gsPz.push(
          {
            i: this.getUUID(),
            type: "范围项",
            classify: "大小于项",
            max: 1000,
            min: 1,
            number: 100
          }
        )
      } else if (t == "小于项") {
        if (this.gsPz.length > 0) {
          if (this.gsPz[0].type != '范围项') {
            this.gsPz = [];
          }
        }
        this.gsPz.push(
          {
            i: this.getUUID(),
            type: "范围项",
            classify: "小于项",
            max: 1,
            min: 0,
            number: 100
          }
        )
      } else {
        this.gsPz.push(
          {
            i: this.getUUID(),
            type: "符号项",
            value: t
          }
        )
      }
    },
    del() {
      if (this.gsPz.length > 0) {
        this.gsPz.splice(this.gsPz.length - 1, 1);
      }
    },
    save() {
      if (this.gsPz.length == 0) {
        this.dataForm.gsPz = "";
        this.dataForm.gsZs = "";
        this.dataForm.gsYs = "";
        this.dataForm.gsYz = 0;
        this.eSave();
      } else {
        let jsStr = "";
        this.dataForm.gsZs = "";
        let gsYs = [];
        for (var i in this.gsPz) {
          var r = this.gsPz[i];
          if (r.type == "过程项" && r.id == "") {
            this.$notify.closeAll();
            this.$notify.error({
              message: "请选择公式里的过程项",
              showClose: false,
              duration: 3000
            })
            return;
          }
          if (r.type == "范围项" && (r.number == "" || isNaN(r.number) || (r.number + "").indexOf(" ") != -1)) {
            this.$notify.closeAll();
            this.$notify.error({
              message: "请填写公式里的数值项",
              showClose: false,
              duration: 3000
            })
            return;
          }
          if (r.type == "常数项" && (r.number == "" || isNaN(r.number) || (r.number + "").indexOf(" ") != -1)) {
            this.$notify.closeAll();
            this.$notify.error({
              message: "请填写公式里的常数项",
              showClose: false,
              duration: 3000
            })
            return;
          }
          if (r.type == "过程项") {
            jsStr += "100";
            this.dataForm.gsZs += this.options[r.id].name;
            for (var j in this.options[r.id].ysList) {
              if (gsYs.indexOf(this.options[r.id].ysList[j]) == -1) {
                gsYs.push(this.options[r.id].ysList[j])
              }
            }
          } else if (r.type == "常数项") {
            jsStr += r.number;
            this.dataForm.gsZs += r.number;
          } else if (r.type == "范围项") {

            jsStr += r.number;
            if (r.classify == "小于项") {
              this.dataForm.gsZs += "【 分值 ≤ " + r.max + " 时 = " + r.number + " 】";
            }
            if (r.classify == "大小于项") {
              this.dataForm.gsZs += "【 " + r.min + "﹤ 分值 ≤" + r.max + " 时 = " + r.number + " 】";
            }
            if (r.classify == "大于项") {
              this.dataForm.gsZs += "【 " + r.min + " ﹤ 分值 时 = " + r.number + " 】";
            }

          } else {
            jsStr += r.value;
            if (r.value == "+") {
              this.dataForm.gsZs += "＋";
            } else if (r.value == "-") {
              this.dataForm.gsZs += "－";
            } else if (r.value == "*") {
              this.dataForm.gsZs += "×";
            } else if (r.value == "/") {
              this.dataForm.gsZs += "÷";
            } else if (r.value == "(") {
              this.dataForm.gsZs += "(";
            } else if (r.value == ")") {
              this.dataForm.gsZs += ")";
            }
          }
        }
        if (this.gsPz[0].type == '范围项') {
          this.dataForm.gsPz = JSON.stringify(this.gsPz);
          this.dataForm.gsYz = 1;
          this.dataForm.gsYs = JSON.stringify(gsYs);
          this.eSave();
          return;
        }
        try {
         //console.log(jsStr)
          var s = eval(jsStr);
          this.dataForm.gsPz = JSON.stringify(this.gsPz);
          this.dataForm.gsYz = 1;
          this.dataForm.gsYs = JSON.stringify(gsYs);
          this.eSave();
        } catch (e) {
          this.$notify.closeAll();
          this.$notify.error({
            message: "编写的公式不是有效的数学公式",
            showClose: false,
            duration: 3000
          })
        }
      }
    },
    eSave() {
      putObj(this.dataForm).then(data => {
        this.$notify.success('配置成功')
        this.dialogVisible = false;
        this.$emit('refreshDataList')
      }).catch(() => {
      });
    },
    //开始拖拽事件
    onStart() {
      this.drag = true;
    },
    //拖拽结束事件
    onEnd() {
      this.drag = false;
    },
    getUUID(len, radix) {
      //获取UUID
      var chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz".split(
        ""
      );
      var uuid = [],
        i;
      radix = radix || chars.length;

      if (len) {
        // Compact form
        for (i = 0; i < len; i++) uuid[i] = chars[0 | (Math.random() * radix)];
      } else {
        // rfc4122, version 4 form
        var r;

        // rfc4122 requires these characters
        uuid[8] = uuid[13] = uuid[18] = uuid[23] = "-";
        uuid[14] = "4";

        // Fill in random data.  At i==19 set the high bits of clock sequence as
        // per rfc4122, sec. 4.1.5
        for (i = 0; i < 36; i++) {
          if (!uuid[i]) {
            r = 0 | (Math.random() * 16);
            uuid[i] = chars[i == 19 ? (r & 0x3) | 0x8 : r];
          }
        }
      }
      return uuid.join("");
    }
  }
}
</script>

<style lang="scss" scoped>


</style>
